<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>具体评教页面</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" href="/static/index/amazeui/css/amazeui.min.css"/>
<link rel="stylesheet" href="/static/index/default/style.css"/>
<script src="/static/index/amazeui/js/jquery.min.js"></script>
<script src="/static/index/amazeui/js/amazeui.min.js"></script>
<link rel="stylesheet" href="/static/index/js/layer/mobile/need/layer.css" />
<link rel="stylesheet" href="/static/index/css/iCheck/custom.css" />
<script src="/static/index/js/layer/mobile/layer.js"></script>
<script src="/static/index/js/iCheck/icheck.min.js"></script>
</head>

<body>
<div class="container">
	<header data-am-widget="header" class="am-header am-header-default my-header">
      <div class="am-header-left am-header-nav">
        <a href="javascript:fanhui();" class="left-fanhui">
          <i class="am-header-icon am-icon-chevron-left"></i>
        </a>
      </div>
      <h1 class="am-header-title">
        <a href="#title-link" class="">{$title}</a>
      </h1>
   </header>
    <div class="am-cf cart-panel">
    	<form id="pjForm" action="" method="post" class="cart-list-panel">
            <ul class="am-avg-sm-1 cart-panel-ul">
      <!--      	<for start="开始值" end="结束值" comparison="" step="步进值" name="循环变量名" >
				
            	</for>-->
            	{volist name="list" id="vo"}
            		{if condition="!$vo['normitem']"}
            		<li style="height: auto;">
	        			<h2 style="width: 100%;margin: 0.6rem 0 0.6rem;border-bottom: 1px dashed;border-top: 1px dashed;">{$vo.name}</h2>
	        			<input type="hidden" value="{--$i}" />
            		</li>
	        		{else /}
		                <li style="height: auto;">
		                	<div class="infopanel" style="width: 100%;padding-top: 1px;">
		                		<h2 style="margin: 0;font-size:1.2em;">{$i}、{$vo.name}</h2>
			                        <div style="margin: 7px 0px 8px 12px;" class="radio i-checks">
			                        	{volist name="vo['normitem']" id="v" key="k"}
			                        	<h3 style="margin: 0;font-size: 1.6rem;">
			                        		 <label class="radio-inline">
			                                    <input type="radio" name="xuanze{$i}"  value='{$v.score}'> {$k}、{$v.name}
			                                </label>
			                        	</h3>
			                        	{/volist}
			                  	</div>
		                    </div>
		                </li>
	                {/if}
				{/volist}
                
               
            </ul>
        </form>
    </div>
    
    <div class="cart-tool">
    	<a class="am-btn am-btn-sm am-btn-success" href="javascript:fanhui();">
          <i class="am-icon-chevron-left"></i>
          返回
        </a>
        <a class="am-btn am-btn-sm am-btn-warning" href="javascript:void(0)">提交评教</a>
    </div>
</div>
<style>
	.layui-m-layercont {
	    padding: 0px 0px 3px;
	}
</style>
<script>
	$(function(){
		$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green"});
	})
	
	$(".am-btn-warning").click(function(){
		console.log($(".cart-list-panel").serialize());
		//获取表单序列为数组，以判断是否选完
		/*if({$list|count}>$(".cart-list-panel").serializeArray().length){
			layer.open({
			  content: '<span style="font-size: 2rem;display: block;padding: 2px 0;">还有未选的选项喔</br>不能提交评教。</span>'
			  ,style: 'background-color:#09C1FF; color:#fff; border:none;' //自定风格
			  ,time: 5
			});
			console.log($(".cart-list-panel").serializeArray());
			console.log({$list[0]['etype_id']});//获取评教类别
			
			return false;
		}
		*/
		var $defen = 0;
		var $arr = $(".cart-list-panel").serializeArray();
		for(var i = 0 ; i<$arr.length; i++){
			$defen += parseFloat($arr[i].value);
		}
		
		console.log($defen);//获取评教类别
		
		$.ajax({
            url: "/index/pingjiao/dopingjiaopost",
            data:{
            	'etask_id' : window.localStorage.getItem('oes_etaskid'),
            	'etype_id' : {$list[0]['etype_id']},
            	'teacher_id' : window.localStorage.getItem('oes_teacherid'),
            	'clazz_id' : window.localStorage.getItem('oes_classid'),
            	'course_id' : window.localStorage.getItem('oes_courseid'),
            	'score' : $defen
            },//$("#pjForm").serialize()+'&',
            type: "POST",
            dataType: 'json',
            success: function(data){
            	console.log(data)
               if (data.success) {
                    layer.open({
					  content: data.msg
					  ,style: 'background-color:#09C1FF; color:#fff; border:none;' //自定风格
					  ,time:2
					});
					setInterval(function(){
						window.location.href=data.obj;
					},2100)
                } else {
                    layer.open({
					  content: data.msg
					  ,style: 'background-color:#09C1FF; color:#fff; border:none;' //自定风格
					  ,time:2
					});
					setInterval(function(){
						window.location.reload();
					},1500)
                }
            }
        });
		
	})
	
	function fanhui(){
		layer.open({
		  title: [
		    '提示',
		    'background-color:#8DCE16; color:#fff;'
		  ]
		  ,anim: 'up'
		  ,content: '<span style="font-size: 2rem;">当前评教未完成，确定要返回上一页吗？</span><br /><em style="color: red ;font-size: 12px">(提示：现在退出当前页，之前的评教将作废哦)</em>'
		  ,btn: ['确定','继续评教']
		  ,shadeClose: false
		  ,yes: function(index){
			 window.history.back();
			}
		  ,no: function(index){
			 layer.close(index)
			} 
		  
		});
	}
</script>
</body>
</html>
